package org.jivesoftware.smackx.provider;

import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smackx.packet.MUCUser;
import org.jivesoftware.smackx.packet.MUCUser.Decline;
import org.jivesoftware.smackx.packet.MUCUser.Destroy;
import org.jivesoftware.smackx.packet.MUCUser.Invite;
import org.jivesoftware.smackx.packet.MUCUser.Item;
import org.jivesoftware.smackx.packet.MUCUser.Status;
import org.xmlpull.v1.XmlPullParser;

public class MUCUserProvider
  implements PacketExtensionProvider
{
  private MUCUser.Decline parseDecline(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Decline localDecline = new MUCUser.Decline();
    localDecline.setFrom(paramXmlPullParser.getAttributeValue("", "from"));
    localDecline.setTo(paramXmlPullParser.getAttributeValue("", "to"));
    while (true)
    {
      int j;
      label85: 
      do
        while (true)
        {
          do
          {
            if (i != 0)
              return localDecline;
            j = paramXmlPullParser.next();
            if (j != 2)
              break label85;
          }
          while (!(paramXmlPullParser.getName().equals("reason")));
          localDecline.setReason(paramXmlPullParser.nextText());
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("decline"))));
      i = 1;
    }
  }

  private MUCUser.Destroy parseDestroy(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Destroy localDestroy = new MUCUser.Destroy();
    localDestroy.setJid(paramXmlPullParser.getAttributeValue("", "jid"));
    while (true)
    {
      int j;
      label71: 
      do
        while (true)
        {
          do
          {
            if (i != 0)
              return localDestroy;
            j = paramXmlPullParser.next();
            if (j != 2)
              break label71;
          }
          while (!(paramXmlPullParser.getName().equals("reason")));
          localDestroy.setReason(paramXmlPullParser.nextText());
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("destroy"))));
      i = 1;
    }
  }

  private MUCUser.Invite parseInvite(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Invite localInvite = new MUCUser.Invite();
    localInvite.setFrom(paramXmlPullParser.getAttributeValue("", "from"));
    localInvite.setTo(paramXmlPullParser.getAttributeValue("", "to"));
    while (true)
    {
      int j;
      label85: 
      do
        while (true)
        {
          do
          {
            if (i != 0)
              return localInvite;
            j = paramXmlPullParser.next();
            if (j != 2)
              break label85;
          }
          while (!(paramXmlPullParser.getName().equals("reason")));
          localInvite.setReason(paramXmlPullParser.nextText());
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("invite"))));
      i = 1;
    }
  }

  private MUCUser.Item parseItem(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Item localItem = new MUCUser.Item(paramXmlPullParser.getAttributeValue("", "affiliation"), paramXmlPullParser.getAttributeValue("", "role"));
    localItem.setNick(paramXmlPullParser.getAttributeValue("", "nick"));
    localItem.setJid(paramXmlPullParser.getAttributeValue("", "jid"));
    while (true)
    {
      int j;
      label133: 
      do
        while (true)
        {
          do
          {
            if (i != 0)
              return localItem;
            j = paramXmlPullParser.next();
            if (j != 2)
              break label133;
            if (paramXmlPullParser.getName().equals("actor"))
              localItem.setActor(paramXmlPullParser.getAttributeValue("", "jid"));
          }
          while (!(paramXmlPullParser.getName().equals("reason")));
          localItem.setReason(paramXmlPullParser.nextText());
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("item"))));
      i = 1;
    }
  }

  public PacketExtension parseExtension(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    MUCUser localMUCUser = new MUCUser();
    int i = 0;
    while (true)
    {
      int j;
      label184: 
      do
        while (true)
        {
          do
          {
            if (i != 0)
              return localMUCUser;
            j = paramXmlPullParser.next();
            if (j != 2)
              break label184;
            if (paramXmlPullParser.getName().equals("invite"))
              localMUCUser.setInvite(parseInvite(paramXmlPullParser));
            if (paramXmlPullParser.getName().equals("item"))
              localMUCUser.setItem(parseItem(paramXmlPullParser));
            if (paramXmlPullParser.getName().equals("password"))
              localMUCUser.setPassword(paramXmlPullParser.nextText());
            if (paramXmlPullParser.getName().equals("status"))
              localMUCUser.setStatus(new MUCUser.Status(paramXmlPullParser.getAttributeValue("", "code")));
            if (paramXmlPullParser.getName().equals("decline"))
              localMUCUser.setDecline(parseDecline(paramXmlPullParser));
          }
          while (!(paramXmlPullParser.getName().equals("destroy")));
          localMUCUser.setDestroy(parseDestroy(paramXmlPullParser));
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("x"))));
      i = 1;
    }
  }
}